% TEST_ID: LANG-EXPAND-0049
% CATEGORY: language/reflection
% 测试 nargout 变量

function test_nargout
    R1 = test_utils(); % Call with one output arguments
    assert(isequal(R1, 1));

    [R1, R2] = test_utils(); % Call with two output argument
    assert(isequal(R1, 21));
    assert(isequal(R2, 22));

    [R1, R2, R3] = test_utils(); % Call with three output arguments
    assert(isequal(R1, 31));
    assert(isequal(R2, 32));
    assert(isequal(R3, 33));
end


function [R1,R2, R3] = test_utils
    switch nargout
        case 0
        case 1
            R1 = 1;
        case 2
            R1 = 21;
            R2 = 22;
        case 3
            R1 = 31;
            R2 = 32;
            R3 = 33;
        otherwise
            error('Too many output arguments');
    end
end

